# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import QWidget, QLineEdit, QApplication, QFormLayout
import sys


class Lin(QWidget):
    def __init__(self, parent=None):
        super(Lin, self).__init__(parent)
        self.setWindowTitle("文本框示例")
        # 实例化表单布局
        fq = QFormLayout()
        #创建4个文本输入框
        PNormalLineEdit = QLineEdit()
        pNoEchoLineEdit = QLineEdit()
        pPasswordListEdit = QLineEdit()
        pPasswordEchoOnEditLineEdit = QLineEdit()

        # flo.addRow(文本名称（可以自定义），文本框)
        fq.addRow('name', PNormalLineEdit)
        fq.addRow('phone', pNoEchoLineEdit)
        fq.addRow('pwd', pPasswordListEdit)
        fq.addRow('ConfirmPassword', pPasswordEchoOnEditLineEdit)

        # 背景提示信息
        PNormalLineEdit.setPlaceholderText('name')
        pNoEchoLineEdit.setPlaceholderText('phone')
        pPasswordListEdit.setPlaceholderText('pwd')
        pPasswordEchoOnEditLineEdit.setPlaceholderText('ConfirmPassword')

        # QLineEdit.Normal：正常显示所输入的字符，此为默认选项
        PNormalLineEdit.setEchoMode(QLineEdit.Normal)
        # QLineEdit.NoEcho：不显示任何输入的字符，常用于密码类型的输入，且长度保密
        pNoEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
        # QLineEdit.Password：显示与平台相关的密码掩饰字符，而不是实际输入的字符
        pPasswordListEdit.setEchoMode(QLineEdit.Password)
        # QLineEdit.PasswordEchoOnEdit：在编辑时显示字符，负责显示密码类型的输入
        pPasswordEchoOnEditLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)

        self.setLayout(fq)
if __name__ == '__main__':
    app = QApplication(sys.argv)
    lin = Lin()
    lin.show()
    sys.exit(app.exec_())
